from google.appengine.ext import webapp
from google.appengine.ext.webapp import template
import os
import wsgiref.handlers

class MapPage(webapp.RequestHandler):
    def get(self, intl = 'cn'):
        self.response.headers['Content-Type'] = 'text/html;charset=utf-8'
        hosts = {"cn": "ditu.google.com", 
                 "hk": "maps.google.com.hk",
                 "tw": "maps.google.com.tw",
        }

        template_values = {
                           'map_host': hosts[intl]
                           }

        path = os.path.join(os.path.dirname(__file__), 'templates', 'maps.html')
        self.response.out.write(webapp.template.render(path, template_values))

class MyPage(webapp.RequestHandler):
    def get(self, intl = 'cn'):
        self.response.headers['Content-Type'] = 'text/html;charset=utf-8'

        template_values = {}

        path = os.path.join(os.path.dirname(__file__), 'templates', 'my.html')
        self.response.out.write(webapp.template.render(path, template_values))

def main():
    application = webapp.WSGIApplication(
                                     [(r'/maps$', MapPage),
                                      (r'/maps/(hk|tw)', MapPage),
                                      ('/my', MyPage)],
                                     debug=True)
    wsgiref.handlers.CGIHandler().run(application)

if __name__ == "__main__":
    main()